#pragma once
#include "Common.h"
#include "CentralCache.h"

class ThreadCache
{
public:
    // 申请内存
    void* Allocate(size_t size);
    // 释放内存
    void Deallocate(void* obj, size_t size);
private:
    // 从cc中获取内存
    void* FetchFromCentralCache(size_t index, size_t size);
    void ListToSpan(FreeList& list, size_t size);
    FreeList _freeLists[list_num];
};

#ifdef _WIN32
static _declspec(thread) ThreadCache* tls_threadcache = nullptr;
#else
static thread_local ThreadCache* tls_threadcache = nullptr;
#endif
